﻿/*
 * Subject：记录器
 * Date：2023/1
 * Context：记录器类负责序列化日志模型和存储日志。如果需要写到数据库，则自行进行修改
 * 
 * **/

namespace Max.PH6_2006A.LowCode.API.LogHander
{
    public interface IRequestResponseLogger
    {
        void Log(IRequestResponseLogModelCreator logCreator);
    }

    public class RequestResponseLogger : IRequestResponseLogger
    {
        private readonly ILogger<RequestResponseLogger> _logger;

        public RequestResponseLogger(ILogger<RequestResponseLogger> logger)
        {
            _logger = logger;
        }
        public void Log(IRequestResponseLogModelCreator logCreator)
        {
            //_logger.LogTrace(jsonString);
            //_logger.LogInformation(jsonString);
            //_logger.LogWarning(jsonString);
            _logger.LogCritical(logCreator.LogString());  //这里就是输出在命令行中，可以写入数据库
        }
    }
}
